import { defineConfig } from "wxt";

export default defineConfig({
  dev: {
    server: {
      port: 5000,
    },
  },
  entrypointsDir: "entrypoints",
  manifest: {
    host_permissions: ["http://*/*", "https://*/*"],
    permissions: ["tabs", "activeTab", "storage", "sidePanel"],
    web_accessible_resources: [
      {
        resources: ["driver.css"],
        matches: ["<all_urls>"],
      },
    ],
    action: {
      default_title: "步骤引导配置",
    },
    side_panel: {
      default_path: "sidepanel.html",
    },
    content_security_policy: {
      extension_pages: "script-src 'self' 'wasm-unsafe-eval' http://localhost:*; object-src 'self';",
      sandbox: "script-src 'self' 'unsafe-inline' 'unsafe-eval' http://localhost:*; sandbox allow-scripts allow-forms allow-popups allow-modals; child-src 'self';"
    },
  },
  hooks: {
    "build:manifestGenerated": (wxt, manifest) => {
      // 移除 popup 配置，只保留 side_panel
      if (manifest.action && manifest.action.default_popup) {
        delete manifest.action.default_popup;
      }
    },
  },
});
